using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Reflection;

namespace BoOnce.Core.Helpers
{
    class Logger
    {
        private static TraceSwitch ts = new TraceSwitch("main.logger", "main switch");

        public static void init()
        {
            TextWriterTraceListener textWriter = new TextWriterTraceListener("log.core.txt");
            textWriter.TraceOutputOptions = TraceOptions.Callstack | TraceOptions.DateTime | TraceOptions.LogicalOperationStack;
            Debug.Listeners.Add(textWriter);   
            Debug.Listeners.Add(new ConsoleTraceListener());
            
            Debug.AutoFlush = true;
            Debug.WriteLine("");
            Debug.WriteLine("==========================================");
            Debug.WriteLine("=               "+DateTime.Now.ToShortDateString() + "               =");
            Debug.WriteLine("==========================================");
            Debug.WriteLine("NAME: " + Version.APPLICATION_NAME);
            Debug.WriteLine("VERSION: " + Version.VERSION);
            Debug.WriteLine("");
        }

        public static void WriteError(Object obj, String msg)
        {
            Debug.WriteLineIf(ts.TraceError, "[ERROR] " + obj.GetType().FullName + " >> " + msg);
        }

        public static void WriteVerbose(Object obj, String msg)
        {
            Debug.WriteLineIf(ts.TraceVerbose, "[VERBOSE] " + obj.GetType().FullName + " >> " + msg);
        }

        public static void WriteWarning(Object obj, String msg)
        {
            Debug.WriteLineIf(ts.TraceWarning, "[WARNING] " + obj.GetType().FullName + " >> " + msg);
        }

        public static void WriteInfo(Object obj, String msg)
        {
            Debug.WriteLineIf(ts.TraceInfo, "[INFO] " + obj.GetType().FullName + " >> " + msg);
        }

        public static void WriteError(String msg)
        {
            Debug.WriteLineIf(ts.TraceError, "[ERROR] " + msg);
        }

        public static void WriteVerbose(String msg)
        {
            Debug.WriteLineIf(ts.TraceVerbose, "[VERBOSE] " + msg);
        }

        public static void WriteWarning(String msg)
        {
            Debug.WriteLineIf(ts.TraceWarning, "[WARNING] " + msg);
        }

        public static void WriteInfo(String msg)
        {
            Debug.WriteLineIf(ts.TraceInfo, "[INFO] " + msg);
        }

    }
}
